static void gtk_label_clear_select_info (GtkLabel *label);
static void gtk_label_update_cursor (GtkLabel *label);
static void gtk_label_clear_layout (GtkLabel *label);
-static void gtk_label_ensure_layout (GtkLabel *label, gboolean guess_wrap_width);
+static void gtk_label_ensure_layout (GtkLabel *label);
static void gtk_label_invalidate_wrap_width (GtkLabel *label);
static void gtk_label_select_region_index (GtkLabel *label,
gint anchor_index,
g_object_unref (existing_layout);
}
- gtk_label_ensure_layout (label, FALSE);
+ gtk_label_ensure_layout (label);
if (pango_layout_get_width (priv->layout) == width)
{
}
static void
-gtk_label_ensure_layout (GtkLabel *label, gboolean guess_wrap_width)
+gtk_label_ensure_layout (GtkLabel *label)
{
GtkLabelPrivate *priv = label->priv;
- PangoRectangle logical_rect;
GtkWidget *widget;
gboolean rtl;
else if (priv->wrap)
{
GtkWidgetAuxInfo *aux_info = _gtk_widget_get_aux_info (widget, FALSE);
- gint longest_paragraph;
- gint width, height;
+ gint width;
gint aux_width = 0;
if ((angle == 90 || angle == 270) && aux_info && aux_info->height > 0)
if (aux_width > 0)
pango_layout_set_width (priv->layout, aux_width * PANGO_SCALE);
- else if (guess_wrap_width == FALSE && allocation.width > 1 && allocation.height > 1)
+ else
{
PangoRectangle rect;
gint xpad, ypad, natural_width;
pango_layout_set_wrap (priv->layout, priv->wrap_mode);
pango_layout_set_width (priv->layout, MAX (width, 1) * PANGO_SCALE);
}
- else
- {
- GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (label));
- gint wrap_width;
-
- pango_layout_set_width (priv->layout, -1);
- pango_layout_get_extents (priv->layout, NULL, &logical_rect);
-
- width = logical_rect.width;
- /* Try to guess a reasonable maximum width */
- longest_paragraph = width;
-
- wrap_width = get_label_wrap_width (label);
- width = MIN (width, wrap_width);
- width = MIN (width,
- PANGO_SCALE * (gdk_screen_get_width (screen) + 1) / 2);
-
- pango_layout_set_width (priv->layout, width);
- pango_layout_get_extents (priv->layout, NULL, &logical_rect);
- width = logical_rect.width;
- height = logical_rect.height;
-
- /* Unfortunately, the above may leave us with a very unbalanced looking paragraph,
- * so we try short search for a narrower width that leaves us with the same height
- */
- if (longest_paragraph > 0)
- {
- gint nlines, perfect_width;
-
- nlines = pango_layout_get_line_count (priv->layout);
- perfect_width = (longest_paragraph + nlines - 1) / nlines;
-
- if (perfect_width < width)
- {
- pango_layout_set_width (priv->layout, perfect_width);
- pango_layout_get_extents (priv->layout, NULL, &logical_rect);
-
- if (logical_rect.height <= height)
- width = logical_rect.width;
- else
- {
- gint mid_width = (perfect_width + width) / 2;
-
- if (mid_width > perfect_width)
- {
- pango_layout_set_width (priv->layout, mid_width);
- pango_layout_get_extents (priv->layout, NULL, &logical_rect);
-
- if (logical_rect.height <= height)
- width = logical_rect.width;
- }
- }
- }
- }
- pango_layout_set_width (priv->layout, width);
- }
}
else /* !priv->wrap */
pango_layout_set_width (priv->layout, -1);
if (priv->wrap)
gtk_label_clear_layout (label);
- gtk_label_ensure_layout (label, FALSE);
+ gtk_label_ensure_layout (label);
if (priv->ellipsize)
{
g_assert (priv->select_info);
- gtk_label_ensure_layout (label, FALSE);
+ gtk_label_ensure_layout (label);
for (l = pango_layout_get_lines_readonly (priv->layout); l; l = l->next)
{
keymap_direction = gdk_keymap_get_direction (gdk_keymap_get_for_display (gtk_widget_get_display (widget)));
cursor_direction = get_cursor_direction (label);
- gtk_label_ensure_layout (label, FALSE);
+ gtk_label_ensure_layout (label);
pango_layout_get_cursor_pos (priv->layout, priv->select_info->selection_end,
&strong_pos, &weak_pos);
GtkStateFlags state;
gint x, y;
- gtk_label_ensure_layout (label, FALSE);
+ gtk_label_ensure_layout (label);
if (priv->text && (*priv->text != '\0'))
{
*index = 0;
- gtk_label_ensure_layout (label, FALSE);
+ gtk_label_ensure_layout (label);
window_to_layout_coords (label, &x, &y);
priv = label->priv;
- gtk_label_ensure_layout (label, FALSE);
+ gtk_label_ensure_layout (label);
return priv->layout;
}
{
g_return_if_fail (GTK_IS_LABEL (label));
- gtk_label_ensure_layout (label, FALSE);
+ gtk_label_ensure_layout (label);
get_layout_location (label, x, y);
}
"gtk-split-cursor", &split_cursor,
NULL);
- gtk_label_ensure_layout (label, FALSE);
+ gtk_label_ensure_layout (label);
pango_layout_get_cursor_pos (priv->layout, index,
&strong_pos, &weak_pos);
gint n_attrs;
gint length;
- gtk_label_ensure_layout (label, FALSE);
+ gtk_label_ensure_layout (label);
length = g_utf8_strlen (priv->text, -1);
gboolean split_cursor;
gboolean strong;
- gtk_label_ensure_layout (label, FALSE);
+ gtk_label_ensure_layout (label);
g_object_get (gtk_widget_get_settings (GTK_WIDGET (label)),
"gtk-split-cursor", &split_cursor,
PangoLogAttr *log_attrs;
gint n_attrs;
- gtk_label_ensure_layout (label, FALSE);
+ gtk_label_ensure_layout (label);
pango_layout_get_log_attrs (priv->layout, &log_attrs, &n_attrs);
PangoLogAttr *log_attrs;
gint n_attrs;
- gtk_label_ensure_layout (label, FALSE);
+ gtk_label_ensure_layout (label);
pango_layout_get_log_attrs (priv->layout, &log_attrs, &n_attrs);